﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UcAsp.Models;
namespace UcAsp.Controllers
{
    public class CourseController : Controller
    {
        //
        // GET: /Course/
        private UcAspNetEntities entities = new UcAspNetEntities();
        public ActionResult Index(int? id)
        {
            List<Categories> list = new List<Categories>();
            if (id == null)
            {
                 list = entities.Categoriess.Where(o => o.ParentID == 11).OrderByDescending(o => o.Rate).ToList();
            }
            else
            {
                 list = entities.Categoriess.Where(o => o.ID == id).OrderByDescending(o => o.Rate).ToList();
            }
            ViewData["Categories"] = list;
            return View();
        }
        public ActionResult ViewCourse(int id)
        {
            List<Articles> art = entities.Articless.Where(o => o.CategorieID == id&o.IsRelease==true).OrderByDescending(o=>o.Rate).ToList();
            return View(art);
        }
        public ActionResult College()
        {
            return View();
        }
    }
}
